<template>
  <div>
    <!-- 基本信息 -->
    <jn-prj-detail :prj-id="urlParams.prjId" />
    <!-- 站址信息 -->
    <jn-site-detail v-if="[14].includes(+detailData.secondaryType)" :prj-id="urlParams.prjId" />
    <!-- 专享信息 -->
    <jn-proprietary-detail :prj-id="urlParams.prjId" :secondary-type="detailData.secondaryType" />
    <t-collapse title="商合采购订单调整情况">
      <pos-detail
        ref="PosDetail"
        :select-list="selectList"
        :form="detailData"
        :url-params="urlParams"
      />
    </t-collapse>
    <!-- 附件  -->
    <zr-attachmetl prj-stage="Q" />
  </div>
<!--  <el-container>-->
<!--    <el-main v-if="componentsShow" class="mainDetails">-->
<!--      &lt;!&ndash; 页面主体内容 &ndash;&gt;-->
<!--      <el-collapse v-for="item in collapseList" :key="item.components" v-model="activeNames">-->
<!--        <template v-if="item.iframe && item.key !== 'file'">-->
<!--          <iframe :ref="item.components" :src="item.url" width="100%" frameborder="0" scrolling="no" />-->
<!--        </template>-->
<!--        <el-collapse-item v-else :name="item.components">-->
<!--          <template v-if="item.title" slot="title">-->
<!--            <i class="item_icon" />{{ item.title }}-->
<!--          </template>-->
<!--          <div class="content-box">-->
<!--            <template v-if="item.iframe">-->
<!--              <iframe :ref="item.components" :src="item.url" width="100%" height="180px" frameborder="0" scrolling="no" />-->
<!--            </template>-->
<!--            <template v-else>-->
<!--              <component-->
<!--                :is="item.components"-->
<!--                :ref="item.components"-->
<!--                :select-list="selectList"-->
<!--                :form="detailData"-->
<!--                :url-params="urlParams"-->
<!--              />-->
<!--            </template>-->
<!--          </div>-->
<!--        </el-collapse-item>-->
<!--      </el-collapse>-->
<!--    </el-main>-->
<!--  </el-container>-->
</template>

<script>
import PosDetail from './posDetail'

// import * as Common from '@/api/common'
// import * as Axios from '@/api/settlement'
import { parseParams } from '@/utils'
import JnSiteDetail from '@/components/jn/JnSiteDetail.vue'
import TCollapse from '@/components/basic/TCollapse.vue'
import ZrAttachmetl from '@/components/zr/ZrAttachmetl.vue'
import JnProprietaryDetail from '@/components/jn/JnProprietaryDetail.vue'
import JnPrjDetail from '@/components/jn/JnPrjDetail.vue'

export default {
  name: 'SettlementDetail',
  components: {
    JnPrjDetail, JnProprietaryDetail, ZrAttachmetl, TCollapse, JnSiteDetail,
    PosDetail
  },
  data() {
    return {
      activeNames: [],
      collapseList: [
        { iframe: true, title: '项目基础详情', components: 'basicInfo', url: null },
        { iframe: true, title: '项目站址信息', components: 'siteInfo', url: null },
        { iframe: true, title: '项目专属信息', components: 'exclusive', url: null },
        { title: '商合采购订单调整情况', components: 'PosDetail' },
        { iframe: true, title: '附件信息', components: 'AttachmentInfo', url: null, key: 'file' }
      ],
      childData: {},
      selectList: {},
      detailData: {},
      componentsShow: false,
      urlParams: {
        nodeNameWord: '',
        prjId: '',
        adjustId: '',
        activityId: '',
        workItemId: '',
        procInstId: '',
        taskId: '',
        taskType: '',
        userId: '',
        orgId: '',
        proId: '',
        city: '',
        activityInstName: '',
        bizSeq: '',
        supplierCode: null
      },
      junNanUrl: process.env.VUE_APP_JUNNAN_IFRAME_URL,
      fileUrl: process.env.VUE_APP_ZHONGRUAN_URL
    }
  },
  async created() {
    // this.urlParams = {
    //   ...parseParams(window.location.hash)
    // }
    // console.log(this.urlParams, '===>?this.urlParams')
    // const { data } = await Axios.getServConfirmParam(this.urlParams)
    // this.urlParams = { ...data }
    // const res = await Axios.getPrjDetail({ prjId: this.urlParams.prjId })
    // for (const i in res.data) {
    //   this.$set(this.detailData, i, res.data[i])
    // }
    // // this.headerTitle = res.data.prjName
    // this.componentsShow = true

    // await this.$nextTick()
    // this.collapseList.map(item => {
    //   if (!item.iframe) {
    //     this.childData[item.components] = this.$refs[item.components][0].$data
    //   }
    // })
    // this.ifarmSrcPram()
  },
  mounted() {
    // this.activeNames = this.collapseList.map(item => item.components)
    // window.addEventListener('message', (event) => {
    //   if (event.data.type === 'basicInfo') {
    //     // this.basicList = JSON.parse(event.data.data)
    //     // console.log('基本信息')
    //   }
    //   if (event.data.type === 'proprietaryInfo') {
    //     // console.log('专属信息')
    //   }
    //   if (event.data.type === 'siteInfo') {
    //     // this.siteInfoList = JSON.parse(event.data.data)
    //     // console.log('站址信息')
    //   }
    //   if (event.data.type === 'attachment') {
    //     this.$refs['AttachmentInfo'][0].style.height = event.data.height + 'px'
    //     // console.log('附件高度')
    //   }
    // })
  },
  methods: {
    // 获取下拉框数据
    async getSelectData() {
      const arr = ['PROJ_TYPE', 'SECONDARY_TYPE', 'BUILD_MODES', 'PURCHASE_METHOD']
      // for (const i in arr) {
      //   const res = await Common.getDropdownData(arr[i])
      //   this.$set(this.selectList, arr[i], res.data)
      // }
    },
    // ifarm src 传参
    // ifarm src 传参
    async ifarmSrcPram() {
      console.log(this.urlParams.prjId, '___this.urlParams.prjId')
      // 基本信息
      this.collapseList.find(item => {
        return item.components === 'basicInfo'
      }).url = `${this.junNanUrl}design/basicInfo?prjId=${this.urlParams.prjId}`
      // 站址信息
      this.collapseList.find(item => {
        return item.components === 'siteInfo'
      }).url = `${this.junNanUrl}design/siteInfo?prjId=${this.urlParams.prjId}`
      //  专属信息
      this.collapseList.find(item => {
        return item.components === 'exclusive'
      }).url = `${this.junNanUrl}design/proprietaryInfo?prjId=${this.urlParams.prjId}`
      console.log(this.collapseList, '====>123')
      // console.log(this.lcList, '00000000000000000000')
      // 附件信息
      this.collapseList.find(item => {
        return item.components === 'AttachmentInfo'
      }).url = `${this.fileUrl}attachmentInfo?prjId=${this.urlParams.prjId}&nodeId=SERVICE_CONFIRM_NODE&prjStage=Q&prjType=${this.detailData.prjType}&buildModes=${this.detailData.buildModes}&towerType=${this.detailData.towerType}&roomType=${this.detailData.roomType}`
      // // 审批信息
      // this.collapseList.find(item => {
      //   return item.components === 'ApprovalList'
      // }).url = `${this.junNanUrl}workflow/taskDetail/handleOnlyRecord?prjId=${this.urlParams.prjId}&processInstID=100000012355`
    }
  }
}
</script>
<style scoped>
.el-collapse {
    margin-bottom: 15px;
    border: 1px solid #EBEEF5;
}
</style>
